<%# $Id: index.rhtml 546 2010-07-19 11:43:11Z toshiyuki.ando1971 $
# To change this template, choose Tools | Templates
# and open the template in the editor.
%>
<style type="text/css">
<!-- div#content {
  background-image: url("<%="#{@hudson.settings.url}images/hudson.png"%>");
  background-position: left bottom;
  background-repeat: no-repeat;
}
<%= render :partial => 'icon_style_hudson' if @hudson.settings.look_and_feel == 'Hudson' %>
<%= render :partial => 'icon_style_plugin' if @hudson.settings.look_and_feel == 'Plugin' %>
-->
</style>
<div class="contextual">
  <span class="icon icon-switch-description-visibility" id="switch-description-visibility"></span>
</div>
<h2><%=l(:label_job_list)%></h2>

<% if @hudson.jobs.length == 0 %>
  <div class="nodata"><%=l(:notice_no_jobs)%></div>
<% else %>
  <div class="flash notice" id="info" style="display:none;"></div>
  <div class="flash error" id="error" style="display:none;"></div>
  <div id="remote-debug" style="display:none;"></div>

  <% @hudson.jobs.each do |job|%>
    <% next unless @hudson.settings.job_include?(job.name) %>
    <div class="contextual<%='-icon24' if @hudson.settings.look_and_feel == 'Hudson'%>">
    <% build_icon = image_tag("#{@hudson.settings.url}images/24x24/clock.gif", :alt => 'build', :class=>'icon-build-request', :id=>"build-request-#{job.name}", :title => l(:label_build_now)) if @hudson.settings.look_and_feel == 'Hudson' %>
    <% build_icon = "[#{l(:label_build_now)}]" if @hudson.settings.look_and_feel == 'Plugin' %>
    <%= build_icon if authorize_for( "hudson", "build" ) %>
    </div>

    <div class="contextual latest-build" id='latest-build-<%=job.name%>'>
      <%=job.latest_build.error if "" != job.latest_build.error%>
      <% if "" == job.latest_build.error %>
        <% if "" != job.latest_build.number %>
          <%=image_tag 'document.png', :class=>'icon-build-history', :id=>"build-history-#{job.name}", :title=>l(:label_show_build_history)%>
          <%=image_tag("#{@hudson.settings.url}images/16x16/package.gif", :class=>"icon-build-artifacts", :id=>"build-artifacts-#{job.name}") unless job.latest_build.artifacts.empty? %>
          <%=link_to "##{job.latest_build.number}", job.latest_build.url_for(:user)%>
          <%=content_tag("span", job.latest_build.result, :class => "result #{job.latest_build.result.downcase}") if true != job.latest_build.building? && "" != job.latest_build.result%>
          <%=content_tag("span", l(:notice_building), :class => "result") if job.latest_build.building? %>
          <% today_tag = "" %>
          <% today_tag = " " + image_tag("today.png", :plugin => "redmine_hudson", :title => l(:label_todays_build)) if is_today?(job.latest_build.finished_at) %>
          <%=content_tag("span", job.latest_build.finished_at.localtime.strftime("%Y/%m/%d %H:%M:%S")) + today_tag if job.latest_build.finished_at %>
        <% end %>
        <%=l(:notice_no_builds) if "" == job.latest_build.number%>
      <% end %>
    </div>

    <div class="job-state" id="job-state-<%="#{job.name}"%>">
    <% icon_base_class = "icon24" if @hudson.settings.look_and_feel == 'Hudson' %>
    <% icon_base_class = "icon" if @hudson.settings.look_and_feel == 'Plugin' %>
    <h3 class="<%=icon_base_class%> icon-<%=job.state%>"><%=link_to job.name, job.url_for(:user)%></h3>
      <div class="wiki job-description">
        <%= textilizable job.description if Hudson.job_description_format == "textile"%>
        <%= job.description unless Hudson.job_description_format == "textile" %>
      </div>

      <ul class="job-health-reports">
        <% job.health_reports.each do |report| %>
          <%="<li>#{link_to(report.description, report.url)} #{report.score}%" if report.url != ""%>
          <%="<li>#{report.description} #{report.score}%" if report.url == ""%>
        <% end %>
      </ul>
    </div>

    <ul class="build-artifacts-list" id="build-artifacts-list-<%="#{job.name}"%>" style="display:none;">
    <% job.latest_build.artifacts.each do |artifact| %>
      <%="<li><a href='#{job.url_for(:user)}/#{job.latest_build.number}/artifact/#{artifact.relative_path}'>#{artifact.display_path}</a>"%>
    <% end %>
    </ul>

  <% end %>

  <div id="build-history" style="display:none;"></div>
  <div id="build-artifacts" style="display:none;">
    <%="#{l(:label_build_artifacts)}" %><hr style="width:18em;"/><div id="build-artifacts-list" style="padding-left:20px;"></div>
  </div>
  <%= javascript_tag "new BuildArtifacts()"  %>
  <%= javascript_tag "new BuildHistory('#{url_for(:controller => 'hudson', :action => 'history', :id=>@project)}')" %>
  <%= javascript_tag "new BuildRequest('#{url_for(:controller => 'hudson', :action => 'build', :id=>@project)}', 'build accepted - ${job_name}', 'build failure - ${job_name}')" if authorize_for( "hudson", "build" ) %>
  <%= javascript_tag "new DescriptionVisibilityController(#{!@hudson.settings[:show_compact]}, '#{l(:label_show_description)}', '#{l(:label_hide_description)}')"%>
<% end %>

<!-- Add Atom Feed -->
<% other_formats_links do |f| %>
        <%= f.link_to 'Atom', :url => { :project_id => @project,  :key => User.current.rss_key } %>
<% end %>

<% content_for :sidebar do %>
  <%= render :partial => 'hudson_sidebar' %>
<% end %>

<style type="text/css"></style>

<% content_for :header_tags do %>
  <%= stylesheet_link_tag "hudson.css", :plugin => "redmine_hudson", :media => "screen" %>
  <%= javascript_include_tag 'build_artifacts', :plugin => "redmine_hudson" %>
  <%= javascript_include_tag 'build_history', :plugin => "redmine_hudson" %>
  <%= javascript_include_tag 'build_request', :plugin => "redmine_hudson" %>
  <%= javascript_include_tag 'description_visibility_controller', :plugin => "redmine_hudson" %>
<% end %>
